package com.chanyachting.emall.action.companyproduct;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.chanyachting.emall.domain.Dock;
import com.chanyachting.emall.form.DockForm;
import com.chanyachting.emall.service.CompanyproductService;
import com.chanyachting.emall.serviceImpl.CompanyproductServiceImpl;
import com.chanyachting.emall.util.DateUtil;

public class CreateDockAction extends Action {
	
	
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		
		DockForm dockForm=(DockForm)form;
		
		Dock dock = null;
		try {
			
			dock=new Dock();
			
			BeanUtils.copyProperties(dock, dockForm);
			
			dock.setTitle(dock.getName());
			
			dock.setCreateDate(DateUtil.getDate());  //设置创建时间
			
			CompanyproductService cpservice=new CompanyproductServiceImpl();
			
			cpservice.createCompanyproduct(dock);  //创建公司产品
			
		} catch (Exception e) {
			
			e.printStackTrace();
		}
		dockForm.setDock(dock);
		
		return mapping.findForward("");
	}
	

}
